home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Games Special 4 / THE BEST OF SELECT Games Special 4 (Select CD-ROM)(1996).iso / dosgames / abuse / lisp / jugger.lsp < prev    next >
Lisp/Scheme  |  1995-09-13  |  9KB  |  303 lines

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licensing information for more details on usage rights
  3.  
  4. (defun jug_ai ()
  5.   (if (<= (hp) 0)
  6.       (if (eq (state) dieing)
  7.       (next_picture)
  8.     (set_state dieing))
  9.     (if (activated)
  10.     (progn       
  11.       (set_targetable T)
  12.       (push_char 35 40)
  13.       (select (aistate) 
  14.           (0 ;; prepare to walk toward player
  15.            (if (eq stationary 0)
  16.                (progn
  17.              (set_state running)
  18.              (go_state 1))
  19.              (if (> (state_time) (aitype))
  20.              (progn
  21.                (set_state weapon_fire)
  22.                (set_aistate 2)))))
  23.  
  24.           (1 ;; walk toward player
  25.            (if (eq stationary 0)
  26.                (progn
  27.              (set_direction (toward))
  28.              (let ((curx (x));; save position in case we fall off a cliff
  29.                    (cury (y)))             
  30.                (if (next_picture) 
  31.                    (if (eq (current_frame) 8)
  32.                    (play_sound JSTOMP_SND 127 (x) (y)))
  33.                  (progn
  34.                    (play_sound JSTOMP_SND 127 (x) (y))
  35.                    (set_state weapon_fire)
  36.                    (set_aistate 2)))
  37.                (if (can_see (x) (y) (x) (+ (y) 5) nil)
  38.                    (progn
  39.                  (set_x curx)
  40.                  (set_y cury)
  41.                  (try_move 0 10)))))
  42.              (if (> (state_time) (aitype))
  43.              (progn
  44.                (set_state weapon_fire)
  45.                (set_aistate 2)))))
  46.  
  47.           (2 ;; start fire
  48.            (if (> (state_time) 3)
  49.                (let ((myself (me))
  50.                  (xspeed (* throw_xvel (direction)))
  51.                  (yspeed throw_yvel))
  52.              (with_object (add_object GRENADE (x) (- (y) 24) 1) 
  53.                       (progn
  54.                     (user_fun myself)
  55.                     (set_xvel xspeed)
  56.                     (set_yvel yspeed)))
  57.              (go_state 3))
  58.              (next_picture)))
  59.           (3 ;; wait for fire animation
  60.            (if (next_picture) nil (set_aistate 0))))
  61.       T) 
  62.       (progn (set_targetable nil)
  63.          T))))
  64.        
  65. (defun jug_cons ()
  66.   (setq throw_xvel 13)
  67.   (setq throw_yvel -10)
  68.   (set_aitype 10))
  69.  
  70. (defun explo_damage_cache (type)
  71.   (list (list EXPLODE6) nil))
  72.  
  73. (def_char JUGGER
  74.   (range 200 0)
  75.   (funs (ai_fun     jug_ai)
  76.     (constructor jug_cons)
  77.     (get_cache_list_fun explo_damage_cache)
  78.     (damage_fun explo_damage))
  79.   (flags (hurtable T))
  80.   (abilities (start_hp    50)
  81.          (push_xrange 1))
  82.   (vars throw_xvel throw_yvel stationary)
  83.   (fields ("hp" "hp")
  84.       ("aitype" "throw speed (0..255)")
  85.       ("throw_xvel" "throw xvel")
  86.       ("throw_yvel" "throw yvel")
  87.       ("stationary"   "stationary? (1=yes,0=no)")
  88.       ("aistate" "aistate"))
  89.  
  90.   (states "art/jug.spe" 
  91.       (stopped "robo0001.pcx")
  92.       (running (seq "rwlk" 1 13))
  93.       (weapon_fire (seq "robo" 1 10))
  94.       (dieing (seq "jugdie" 1 8))))
  95.  
  96. ;; AI for cleaner robot machine "ROB1"
  97. ;; The robot waits for a sensor/switch/gate to turn it
  98. ;; on before appearing
  99. (defun rob1_ai ()
  100.   (if (not (eq (fade_count) 0))             ;; appearing?
  101.       (set_fade_count (- (fade_count) 1)))  ;; fade in
  102.   (select (aistate)
  103.       (0 ;; wait for sensor to turn on
  104.        (if (eq rob_hiden 1)
  105.            (progn
  106.          (set_targetable nil)       ;; can't lock into us while hiden
  107.          (set_state rob_hiding))    ;; set invisible animation frame
  108.          (progn
  109.            (set_targetable T)           ;; can lock into us
  110.            (push_char 30 55)))          ;; push player away
  111.        
  112.        (if (or (< (total_objects) 1)    ;; if not linked or link is on
  113.            (not (eq (with_object (get_object 0) (aistate)) 0)))
  114.            (progn
  115.          (if (eq rob_hiden 1)
  116.              (set_fade_count 15))
  117.          (set_aistate 1)))
  118.        T)
  119.       (1 ;; walk towards player
  120.        (push_char 30 55)                      ;; push her back
  121.        (next_picture)                         ;; go to next animation frame
  122.        (if (eq (mod (state_time) 6) 0)        ;; play sound every 6 ticks
  123.            (play_sound CLEANER_SND 127 (x) (y)))
  124.        (try_move 0 10)                        ;; see how far ahead we can move
  125.        (if (> (direction) 0)                  ;; moving right
  126.            (if (can_see (x) (y) (+ (x) (xvel) 23) (y) nil)   ;; can we see 23 pixels ahead?
  127.              (set_x (+ (x) (xvel))))
  128.          (if (can_see (x) (y) (- (x) (xvel) 23) (y) nil)
  129.            (set_x (- (x) (xvel)))))
  130.  
  131.        (if (<= (hp) 0)                        ;; are we dead, if so blow up
  132.            (progn    
  133.          (add_object EXPLODE1 (+ (x) 5) (- (y) 10)     0)  
  134.          (add_object EXPLODE1 (+ (x) -5) (- (y) 15)    2)  ;; wait 2 frames before appearing
  135.          (add_object EXPLODE1 (+ (x) 10) (- (y) 2)     1)
  136.          (add_object EXPLODE1 (+ (x) -10) (- (y) 20)   3)
  137.          (add_object EXPLODE1 (+ (x) 20) (- (y) 27)    4)
  138.          (add_object EXPLODE1 (+ (x) -25) (- (y) 30)   2)
  139.          (add_object EXPLODE1 (+ (x) 20) (- (y) 5)     4)
  140.          (add_object EXPLODE1 (+ (x) -3) (- (y) 1)     5)
  141.          (set_aistate 2)))
  142.        T)
  143.       (2 ;; dead, wait a few frames then return nil
  144.        (push_char 30 55)
  145.        (< (state_time) 3))))  ;; return nil (dead) if we've been in this state for 3 frames
  146.       
  147.              
  148.  
  149. (defun explo_damage (amount from hitx hity push_xvel push_yvel)   
  150.   (add_object EXPLODE6 (+ (x) (- 10 (random 20))) (- (y) (random 30))     0)
  151.   (damage_fun amount from hitx hity 0 0)
  152.   (if (eq 0 (hp))
  153.       (play_sound BLOWN_UP 127 (x) (y))))
  154.  
  155. (defun rob_cons () (set_xvel 2))
  156.  
  157. (def_char ROB1
  158.   (range 200 0)
  159.   (funs (ai_fun     rob1_ai)
  160.     (constructor rob_cons)
  161.     (get_cache_list_fun explo_damage_cache)
  162.     (damage_fun explo_damage))
  163.   (flags (hurtable T)
  164.      (can_block T))
  165.   (abilities (run_top_speed 4)         
  166.          (start_hp      70)
  167.          (push_xrange   1))
  168.   (vars rob_hiden)
  169.   (fields ("xvel" "xvel")
  170.       ("aitype" "no turn around (1=on)")
  171.       ("rob_hiden"        "hiden start (1=hiden,0=visable)")
  172.       ("hp"     "health"))
  173.   (states "art/rob1.spe" 
  174.       (rob_hiding             "hiding")
  175.       (stopped (seq "clen" 1 10))))
  176.  
  177. (defun who_ai ()
  178.   (if (eq (hp) 0)
  179.       nil
  180.     (progn
  181.       (set_xvel (+ (xvel) (* (+ (mod (state_time) 10) -4) (direction))))
  182.       (if (< (xvel) -15) (set_xvel -15))
  183.       (if (> (xvel) 15) (set_xvel 15))
  184.       (if (not (next_picture)) (set_state stopped))
  185.       (bounce_move '(progn
  186.               (set_direction (- 0 (direction)))
  187.               (set_state turn_around))
  188.            '(progn
  189.               (set_direction (- 0 (direction)))
  190.               (set_state turn_around))
  191.            nil nil nil)
  192.       T)))
  193.   
  194. (defun who_cache (type) `((,STRAIT_ROCKET) nil))
  195.  
  196. (def_char WHO
  197.   (range 200 100)
  198.   (funs (ai_fun flyer_ai)
  199.     (damage_fun  flyer_damage)
  200.     (get_cache_list_fun who_cache)
  201.     (constructor flyer_cons))
  202.  
  203.   (flags (hurtable T))
  204.   (abilities (start_hp 20))
  205.   (vars fire_delay burst_delay burst_total burst_wait burst_left 
  206.     max_xvel   max_yvel    smoke_time fire_time)
  207.   (fields ("fire_delay" "fire_delay")
  208.       ("burst_delay" "burst_delay")
  209.       ("burst_total" "burst_total")
  210.       ("max_xvel"    "max_xvel")
  211.       ("max_yvel"    "max_yvel")
  212.       ("hp" "hp")
  213.       ("aistate" "aistate"))
  214.  
  215.   (states "art/rob2.spe" 
  216.       (stopped (seq "wgo" 1 3))
  217.       (running (seq "wgo" 1 3))
  218.       (turn_around (seq "wtrn" 1 9))
  219.       (flinch_up  '("flinch" "flinch" "flinch"))
  220.       ))
  221.  
  222.  
  223. /*   --- not working
  224. (defun burst_fire (firex firey angle)
  225.   (if (> fire_time 0);; if we need to wait till next burst
  226.       (progn
  227.     (setq fire_time (- fire_time 1))
  228.     (if (eq fire_time 0)
  229.         (progn 
  230.           (setq burst_left burst_total)
  231.           (setq burst_wait 0))))
  232.     (if (eq burst_wait 0)
  233.     (progn
  234.       (if (or (eq burst_left 1) (eq burst_left 0))
  235.           (setq fire_time fire_delay)
  236.         (setq burst_left (- burst_left 1)))
  237.       (setq burst_wait burst_delay)
  238.       (fire_object (me) (aitype) firex firey angle (bg)))
  239.       (setq burst_wait (- burst_wait 1)))))
  240.  
  241.  
  242. (defun wrob_cons ()      
  243.   (setq fire_delay 4)
  244.   (setq burst_delay 1)
  245.   (setq max_xvel 10)
  246.   (setq max_yvel 5)
  247.   (set_aitype 0)
  248.   (setq burst_total 5))
  249.  
  250.  
  251. (defun wrob_ai ()
  252.   (if (eq (hp) 0)
  253.       nil
  254.     (progn
  255.       (select (aistate)
  256.           (0;; walk toward player
  257.            (if (or (> (distx) 120) (not (eq (direction) (toward))))
  258.            (progn
  259.              (move (toward) 0 0)
  260.              (next_picture))
  261.          (progn
  262.            (set_state stopped)
  263.            (set_aistate 1))))
  264.           (1;; stop and fire
  265.            (burst_fire  (+ (x) (* (direction) 28)) (- (y) 35)              
  266.                 (if (> (direction) 0)
  267.                 (mod (- 375 (/ (* burst_left 30) burst_total)) 360)
  268.                   (+ 165 (/ (* burst_left 30) burst_total))))
  269.            (if (not (eq fire_time 0))
  270.            (set_aistate 0))))
  271.       T)))
  272.           
  273.     
  274.  
  275.  
  276. (def_char WALK_ROB
  277.   (funs (ai_fun wrob_ai)
  278.     (constructor wrob_cons)    
  279.     (damage_fun  guner_damage))
  280.   (abilities (run_top_speed 12))
  281.   (flags (hurtable T) (can_block T))
  282.   (range 300 100)